home *** CD-ROM | disk | FTP | other *** search
- Path: news.iadfw.net!usenet
- From: alpet@airmail.net (Adam Peterson)
- Newsgroups: comp.lang.c
- Subject: Re: HELP: UNIX's directory functions.
- Date: Fri, 23 Feb 1996 03:55:08 GMT
- Organization: customer of Internet America
- Message-ID: <4gj6ug$o0h@news-f.iadfw.net>
- References: <Pine.ULT.3.91.960217002153.21669B-100000@hertz.njit.edu> <824598921snz@genesis.demon.co.uk> <4gigogINN8nq@keats.ugrad.cs.ubc.ca>
- NNTP-Posting-Host: dal24-12.ppp.iadfw.net
- X-Newsreader: Forte Free Agent 1.0.82
-
- c2a192@ugrad.cs.ubc.ca (Kazimir Kylheku) wrote:
-
- >In article <824598921snz@genesis.demon.co.uk>,
- >Lawrence Kirby <fred@genesis.demon.co.uk> wrote:
- > >In article <Pine.ULT.3.91.960217002153.21669B-100000@hertz.njit.edu>
- > > dxp8108@hertz.njit.edu "Dharmesh Patel" writes:
- > >
- > >>
- > >>Hi all!
- > >>
- > >>I need help with couple of things in C. I need to know how the functions
- > >>opendir, readdir, closedir, and rewinddir work. I also need to know the
- > >>elements of the struct dirent.
- > >
- > >Unfortunately these are not defined in C.
- > >
- > >>The reason for this request is that I have to write a program that
- > >>simulates the unix command 'pwd', the hard way.
- > >
- > >They are Unix/POSIX defined functions and the place to ask about them
- > >is comp.unix.programmer.
-
- >...and I might add that the revered "K&R" book does cover the basic UNIX
- >programming interface, including directory functions, stat() and other goodies.
-
- >It sounds like you don't have this book. Shame! :)
-
- To answer the original question, Unix treats directories like files,
- thus the open, read, close, rewind functions. To process a list of
- files do something like this:
-
- if opendir succeeds
- {
- while not eof dir
- readdir
- closedir
- }
-
- It's been a while since i've done Unix, but thats basically it...
-
- Adam
-
-
-
-
-